

import Layout from "@/page/layout.jsx"
import { useEffect, useState } from 'react';
import { getCodeTargetList } from './api/task';
import { notification } from 'antd/lib';
import { getUrlParam } from './utils/getUrlData';
import { Provider } from "./app-context/main-context";
const curYear = new Date().getFullYear().toString();
const auth = getUrlParam("auth");
sessionStorage.token = auth;
getCodeTargetList()//获取配置
const App = () => {

    // 筛选条件
    const [condition, setCondition] = useState({
        createBy: getUrlParam("userCode"),
        operateBy: getUrlParam("userCode"),
        // 时间类型
        data: getUrlParam("data"),
        dateType: "tYear",
        comCode: getUrlParam("secComCode"),
        comSName: decodeURI(getUrlParam("comSName")),
        statDate: curYear,
    })
    const [comName, setComName] = useState("")

    const urlConfig = {
        secComCode: getUrlParam("secComCode"),
        comSName: decodeURI(getUrlParam("comSName")),
        userCode: getUrlParam("userCode"),
        data: getUrlParam("data"),
        auth: getUrlParam("auth")
    }


    // 判断是否IE浏览器
    useEffect(() => {
        function isIE(placement) { //ie?
            if (!!window.ActiveXObject || "ActiveXObject" in window) {
                notification.warning({
                    message: `警告`,
                    description:
                        '数据大屏为图形化界面，您当前使用的IE浏览器可能无法显示部分页面效果，建议使用其他浏览器。',
                    placement,
                    duration: null
                });

            }
        }
        isIE("top")
    }, [])



    return (
        <>
            <Provider value={{ setCondition, condition, data: condition.data, comName, setComName }}>
                <div className="App">
                    <Layout urlConfig={urlConfig} />
                </div>
            </Provider>
        </>
    );
}

export default App;
